import "reflect-metadata";

// 为类定义元数据
@Reflect.metadata("info", "地球人")
class People {
  @Reflect.metadata("descible1", "居住地为主要城市")
  @Reflect.metadata("descible2", "上海")
  place: Array<string> = ["中国", "北京"];

  @Reflect.metadata("firstname", "第一个名字")
  @Reflect.metadata("lastname", "最后一个名字")
  getFullName(name: string, age: string): number {
    return 100;
  }
}

/* console.log(Reflect.getMetadata("descible1", People.prototype, "place"));
console.log(Reflect.getMetadata("descible2", People.prototype, "place"));
const types1 = Reflect.getMetadataKeys(People.prototype, "getFullName");
types1.forEach((metaKey) => {
  console.log(
    metaKey,
    Reflect.getMetadata(metaKey, People.prototype, "getFullName")
  );
}); */

const types2 = Reflect.getMetadataKeys(People.prototype, "place");
console.log(types2);
types2.forEach((metaKey) => {
  console.log(metaKey, Reflect.getMetadata(metaKey, People.prototype, "place"));
});
